package pl.poznan.put.cs.idss.particlefilter.agent;

import java.io.IOException;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

import pl.poznan.put.cs.idss.particlefilter.enviroment.Lighthouse;
import pl.poznan.put.cs.idss.particlefilter.enviroment.WorldMap;

public class Particle extends Agent implements Serializable {

	private double weight;
	
	public double getWeight() {
		return weight;
	}

	public void setWeight(double weight) {
		this.weight = weight;
	}

	public Particle(WorldMap map) throws InterruptedException, IOException {
		super(map);
	}

	/**
	 * calculates how likely a measurement should be
	 */
	public double getMeasurementProbability(Map<Lighthouse,Double> measurement){
		double prob = 1.0;
		for (Lighthouse l : measurement.keySet()) {
			double dist = l.getPos().distance(pos);
			double measure = measurement.get(l);
			double tempProb = gaussianTool.getGaussianProbability(dist, senseNoise, measure);
			prob *= tempProb;
		}
		return prob;
	}
	
	@Override
	public void printVector(){
		super.printVector();
		System.out.println("Weight "+weight);
	}
}
